package com.my.hp_hr.contorller;

import com.my.hp_hr.entity.History;
import com.my.hp_hr.service.HistoryService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/historyAddServlet")
public class EmployeeAddServlet extends HttpServlet {
    private HistoryService historyService = new HistoryService();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        try {
            String employeeNumber = req.getParameter("employeeNumber");
            String name = req.getParameter("name");
            String password = req.getParameter("password");
            String gender = req.getParameter("gender");
            String date = req.getParameter("date");
            String telephone = req.getParameter("telephone");
            String email = req.getParameter("email");
            String address = req.getParameter("address");
            String education = req.getParameter("education");
            String departmentNumber = req.getParameter("departmentNumber");
            String positionNumber = req.getParameter("positionNumber");
            String notes = req.getParameter("notes");
//        System.out.println(employeeNumber+","+name+","+password+","+gender+","+date+","+telephone+","+
//                email+","+address+","+education+","+departmentNumber+","+positionNumber+","+notes);
            historyService.addHistory(employeeNumber,name,password,gender,date,telephone,email,address,education,departmentNumber,positionNumber,notes);
            req.getRequestDispatcher("employeeGetListServlet").forward(req,resp);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}
